﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MegavaniaX;

namespace MegavaniaX
{
    /// <summary>
    /// SpriteManager class.  Handles sprite-related rendering duties.
    /// </summary>
    public static class SpriteManager
    {
        private static Dictionary<String, MegavaniaSprite> spriteDictionary = new Dictionary<String, MegavaniaSprite>();

        /// <summary>
        /// Adds a sprite into the dictionary.
        /// </summary>
        /// <param name="name">Name of the dictionary entry</param>
        /// <param name="sprite">Sprite entry</param>
        public static void AddSprite(String name, MegavaniaSprite sprite)
        {
            spriteDictionary.Add(name, sprite);
        }

        /// <summary>
        /// Retrieves a sprite from the dictionary.
        /// </summary>
        /// <param name="name">Name of the sprite.</param>
        /// <returns>The sprite, if it exists.</returns>
        /// <remarks>Needs to throw an exception if the sprite is not found.</remarks>
        public static MegavaniaSprite GetSprite(String name)
        {
            if (!spriteDictionary.ContainsKey(name))
            {
                throw new MegavaniaException("Could not find sprite with name " + name);
            }
            return spriteDictionary[name];
        }
    }
}
